/*
 * This class is a singleton class,you can use getInstance() to get a single President.
 * 
 * public:
 * 	public static President getInstance();
 * 
 * private:
 * 	private String name;
 *  private static President instance;
 * 
 * @copyleft 2015
 */

package singleton;

public class President
{

	private String name;
	private static President instance;

	// a private constructor can make sure that others con't new a project
	private President(String name)
	{
		this.name = name;
	}

	// a public method that others can get the instance
	public static President getInstance(String name)
	{
		if (instance == null && !name.equals(null))
		{
			instance = new President(name);
		}
		return instance;
	}

	// a public method that get the instance's name
	public String getName()
	{
		return this.name;
	}

}
